<template>
	<view class="HistoryAnswers">
		<view class="header">
			
		</view>
		<view class="HistoryAnswers-list" v-for="item in dataList" :key="item.id">
			<view class="dateTime">
				<text class="date">{{item.date}}</text><text class=""time>{{item.dateTime}}</text>
			</view>
			<view class="fractionAndCategory">
				<text class="fraction">{{item.fraction}}分</text>
				<text class="category" v-if="item.status" >完成答题</text>
				<text class="category categorycolor" v-else>提前交卷</text>
			</view>
			
		</view>
	  <view class="footer">
	  	<image class="footerimg" src="https://wlsy.nanjingyunpeng.cn/weixin/image/footerImg.png"></image>
	  </view>
	</view>
</template>

<script>
	import {
		userquestionlogs
	} from "../../api/api.js"
	export default {
		data() {
			return {
	         dataList:[],
			}
		},
		onLoad() {
			this.userquestionlogs()
		},
		methods:{
		async userquestionlogs(){
				let res = await userquestionlogs()
				if(res.code==1000){
					res.data.forEach((item,index)=>{
						this.dataList.push({
							id:item.id,
							dateTime:item.created_at,
							status:item.status,
							uid:item.uid,
							// fraction:item.question_json.length*5
							question_json:JSON.parse(item.question_json)
						})
					})
					this.dataList.forEach((item,index)=>{
						let sum = 0
						item.question_json.forEach((itemSub,indexSub)=>{
							if(itemSub.type==1){
								sum += 5
							}
						})
						// console.log("历史大题列表",sum)
						this.dataList[index].fraction = sum
					})
					// console.log("历史大题列表",this.dataList)
				}
			}
		}
		
	}
	
</script>

<style scoped lang="scss">
	.HistoryAnswers{
		min-width: 100%;
		min-height: 100%;
		background-color: #EEF7FE;
		padding: 30rpx;
		padding-top: 70rpx;
		box-sizing: border-box;
		z-index: 999;
		.header{
			width: 750rpx;
			height: 40rpx;
			background:#466EE7 ;
			border-radius: 0rpx 0rpx 60rpx 60rpx;
			position: fixed;
			top: 0;
			left: 0;
		}
		.HistoryAnswers-list{
			width: 690rpx;
			height: 194rpx;
			background: #FFFFFF;
			box-shadow: 0px 2rpx 8rpx 0px rgba(51,51,51,0.05);
			border-radius: 30rpx 30rpx 30rpx 30rpx;
			opacity: 1;
			margin-bottom: 20rpx;
			padding: 30rpx;
			box-sizing: border-box;
			display: flex;
			justify-content: space-between;
			flex-direction: column;
			.dateTime{
				font-size: 30rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				color: #333333;
				line-height: 36rpx;
				.time{
					display:inline-block;
					margin-left: 20rpx;
				}
			}
			.fractionAndCategory{
				display: flex;
				justify-content: space-between;
				.fraction{
					font-size: 26px;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
					color: #4B73EA;
					line-height: 60rpx;
				}
				.category{
					font-size: 15px;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #4B73EA;
					line-height: 18px;
				}
				.categorycolor{
					color: #CA1313
				}
			}
		}
		.footer {
			width: 750rpx;
			height: 324rpx;
			position: fixed;
			bottom: 0;
			left: 0;
		
			.footerimg {
				width: 100%;
				height: 100%;
			}
		}
	}
</style>